// 盛水最多的容器

/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function (height) {
  let result = 0
  let left = 0, right = height.length - 1
  while (left < right) {
    let cur = Math.min(height[left], height[right]) * (right - left)
    result = Math.max(result, cur)
    if (height[left] < height[right]) {
      left++
    } else {
      right--
    }
  }

  return result
};


console.log(maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7])); // 49
